import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-09-06
 * Time: 19:13
 */

public class Main{
    public static String longestNumberString(String s) throws IOException {
        //遇到数字字符就开始计数,遇到字母就停止计数,计算出最大的
        char[] str = s.toCharArray();
        String[] s2 = new String[255];
        StringBuilder res = new StringBuilder();
        for(int i =0;i<str.length;++i){
            if(str[i]>='0'&&str[i]<='9'){
                res.append(str[i]);
            }else {
                if(s2[0].length()<res.length()){
                    s2[0] = res.toString();
                }else {
                    res = new StringBuilder();
                }
            }
        }
        return s2[0].toString();

    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextLine()){
            String str = scan.nextLine();
           // String ret = longestNumberString(str);
           // System.out.println(ret);
        }
    }
}
//
//import java.util.*;
//
//public class Main{
//    public static String longestNumberString(String s){
//        //遇到数字字符就开始计数,遇到字母就停止计数,计算出最大的
//        char[] str = s.toCharArray();
//        String[] s2 = new String[256];
//        int index = 0;
//        StringBuilder res = new StringBuilder();
//        for(int i =0;i<str.length;++i){
//            if(str[i]>='0'&&str[i]<='9'){
//                res.append(str[i]);
//            }else {
//                s2[index++] = res.toString();
//                res = new StringBuilder();
//            }
//        }
//        s2[index++] = res.toString();
//        int max = 0;
//        HashMap<Integer,Integer> map = new HashMap();
//        for(int i =0;i<index;++i){
//            max = Math.max(max,s2[i].length());
//            map.put(max,i);
//        }
//        return s2[map.get(max)];
//    }
//
//    public static void main(String[] args){
//        Scanner scan = new Scanner(System.in);
//        while(scan.hasNextLine()){
//            String str = scan.nextLine();
//            String ret = longestNumberString(str);
//            System.out.println(ret);
//        }
//    }
//}


class Main1{
    public static int number(int[] arr,int n){
        int  i = 0;
        int ans = 0;
        int min = 0;
        while(i+1<n){
            //递减法的
            while(i+1<n&&arr[i]>=arr[i+1]){
                while(i+1<n&&arr[i]>=arr[i+1]){
                    i++;
                }
                ans++;
            }
            while(i+1<n&&arr[i]<=arr[i+1]) {//递增的
                while(i+1<n&&arr[i]<=arr[i+1]){
                    i++;
                }
                ans++;
            }
        }
        return ans;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()){
            int n = scan.nextInt();
            int[] arr = new int[n];
            for(int i =0;i<arr.length;++i){
                arr[i] = scan.nextInt();
            }
            int ret = number(arr,n);
            System.out.println(ret);
        }
    }
}